<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>新漫监控平台</title>
    <link rel="stylesheet" href="css/layout.css">
    <link rel="shortcut icon" href="images/logo1.ico"/>
    <script src="js/jquery.js"></script>
    <script src="js/jquery.slimscroll.min.js"></script>
    <script src="js/utils.js"></script>
    <script src="js/common.js"></script>
    <script src="js/layer/layer.js"></script>
    <script src="js/index.js"></script>
</head>

<body class="dataManager">
<img src="images/bg1.jpg" class="bgimg" alt="">
<div class="contentbox mainboxSystem">
    <div class="title">
        <span>后台管理界面</span>
        <span>|</span>
        <span class="small-title">SIMMAX</span>
        <div class="avatar-box">
            <img src="images/bg.jpg" class="avatar" alt="">
            <span class="ava-name">LIULISHEJUZHE</span>
        </div>
        <div class="setting-box">
            <a href="#">
                <img src="images/back.png" alt=""> 退出
            </a>
        </div>
    </div>
    <ul class="menu-box">
        <li class="menu1 ">
            <a href="interface.html">连接设备</a>
        </li>
        <li class="menu2">
            <a href="index.html">实时监控</a>
        </li>
        <li class="menu6">
            <a href="dataManager.html">数据管理</a>
        </li>
        <li class="menu3">
            <a href="Parameters.html">参数设置</a>
        </li>
        <li class="menu4 ">
            <a href="user.html">用户管理</a>
        </li>
        <li class="menu5">
            <a href="#">帮助</a>
        </li>
        <li class="menu7 active">
            <a href="systemLog.html">日志管理</a>
        </li>
    </ul>
    <div class="mainbox">
        <div class="user-form">
            <form action="">
                <div class="systemLog">
                    <div class="systemlogActive active">
                        <img src="images/systemLog2.png" alt="">操作日志
                    </div>
                    <div class="systemlogActive">
                        <img src="images/systemLog1.png" alt="">报警日志
                    </div>
                </div>
            </form>
        </div>
        <div class="systemlogscreen">
            <div class="data-timeBox timeBoxsystem ">
                <span>起始时间：</span>
                <div class="data-time">
                    <input type="text" class="demo-input" placeholder="开始时间" id="startDate" lay-key="1">
                </div>
            </div>
            <div class="data-timeBox timeBoxsystem">
                <span>结束时间：</span>
                <div class="data-time">
                    <input type="text" class="demo-input" placeholder="结束时间" id="endDate" lay-key="2">
                </div>
            </div>
        </div>
        <div id="screenbox">
            <span class="slimTop"></span>
            <span class="slimBottom"></span>
            <div class="data-tablelist">
                <style>
                    table{
                        border-collapse: collapse;
                        border:1px solid #aaa;
                        width:100%;
                        text-align: center;
                    }
                    td{
                        border: 1px solid #aaa;
                    }
                </style>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    $(".data-tablelist").slimScroll({
        height: '370px',
        size: "10px",
        alwaysVisible: true,
        opacity: 1,
        railVisible: true,
        //        railColor:"#2d2d2d",
        railColor: 'url("images/scroll_bg.png")',
        railOpacity: 1,
        railBorderRadius: "7px",
        railDraggable: true
    });
    /*点击获取数据*/
    function getDeviceInfo(){
        var data = {
            count: 100,
            // fromTime: $("#startDate").val() || utils.formatTime(new Date()),
            fromTime: $("#startDate").val() ,
            // toTime: $('#endDate').val() || utils.formatTime(new Date()),
            toTime: $('#endDate').val(),
            page: 1,
        };
        $.ajax({
            type:"post",
            url: apiDomain + systemOperate,
            xhrFields: {
                withCredentials: true
            },
            crossDomain: true,
            data: data,
            success: function (data) {
               var data=data.data.list;
               var dataLength=data.length;
                var num='';
               for(var i=0;i<dataLength;i++){
                   num+="<tr><td>" + data[i].createTime + "</td><td>" + data[i].adminName+ "</td><td>" + data[i].type + "</td></tr>";
               };
               if(num!=''){
                   $('.data-tablelist').append("<table class='data-table' cellpadding='0' cellspacing='0'><thead class='data-title'><tr><td>操作时间</td><td>操作用户</td><td>修改类别</td></tr><tbody>"+num+"</tbody></thead></table>");
               }
            }
        });
    }
    /*点击进行切换*/
    $('.systemLog .systemlogActive').on('click',function(){
        $(this).addClass('active').siblings().removeClass('active');
        var _index=$(this).index();
        if(_index==0){
            $('.data-tablelist').html('');
            getDeviceInfo();
        }else{
            $('.data-tablelist').html('');
            postDeviceInfo();
        }
    });
    function postDeviceInfo(){
        var data = {
            count: 100,
            // fromTime: $("#startDate").val() || utils.formatTime(new Date()),
            fromTime: $("#startDate").val() ,
            // toTime: $('#endDate').val() || utils.formatTime(new Date()),
            toTime: $('#endDate').val(),
            page: 1,
        };
        $.ajax({
            type:"post",
            url: apiDomain + systemAlarm,
            xhrFields: {
                withCredentials: true
            },
            crossDomain: true,
            data: data,
            success: function (data) {
                console.log(data);
                var data=data.data.list;
                var dataLength=data.length;
                var num='';
                for(var i=0;i<dataLength;i++){
                    var alarmEndTime=data[i].alarmEndTime;
                    if(alarmEndTime==undefined){
                        alarmEndTime='';
                    }
                    var adminName=data[i].adminName;
                    if(adminName==undefined){
                        adminName='';
                    }
                    num+="<tr><td>" + adminName + "</td><td>" + data[i].alarmStartTime+ "</td><td>" + alarmEndTime + "</td><td>"+data[i].createTime+"</td><td>"+ Math.floor(data[i].doserate * 100) / 100+"</td></tr>";
                };
                if(num!=''){
                    $('.data-tablelist').append("<table class='data-table data-title2' cellpadding='0' cellspacing='0'><thead class='data-title'><tr><td>作业人员</td><td>开始时间</td><td>结束时间</td><td>消除记录时间</td><td>报警值</td></tr><tbody>"+num+"</tbody></thead></table>")
                }
            }
        });
    }
    getDeviceInfo();
</script>
<script src="laydate/laydate.js"></script>
<script>
    laydate.render({
        elem: '#startDate',
        type: 'datetime',
        // value: new Date(new Date().getTime() - 24 * 3600 * 1000)
    });
    laydate.render({
        elem: '#endDate',
        type: 'datetime',
        // value: new Date()
    });


</script>

</html>